package com.wolfman.wolfchat.vo;

import lombok.Data;

/**
 * @Title
 * @Description
 * @Author WolfMan
 * @Date 2022/1/15 0:42
 * @Email 2370032534@qq.com
 */
@Data
public class Result {

    /**
     * 操作是否成功
     */
    private boolean flag;
    /**
     * 信息
     */
    private String message;
    /**
     * 数据
     */
    private Object data;

    private Result(Object data) {
        this.flag = true;
        this.message = "success";
        this.data = data;
    }

    private Result(String message, Object data) {
        this.flag = true;
        this.message = message;
        this.data = data;
    }

    private Result(String message) {
        this.flag = false;
        if (message == null) {
            return;
        }
        this.message = message;
    }

    public static Result success(Object data) {
        return new Result(data);
    }

    public static Result success(String message, Object data) {
        return new Result(message, data);
    }

    public static Result error(String message) {
        return new Result(message);
    }

    @Override
    public String toString() {
        return "Result{" +
                "flag=" + flag +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}